/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package common;

import com.toedter.calendar.JDateChooser;
import java.util.Calendar;

/**
 *
 * @author KIENLT
 */
public class CalendarFormat {
    public static Calendar setCalendar(String date) {
        Calendar c = Calendar.getInstance();
        String strDate = date.split(" ")[0].toString();
        String strDateValue[] = strDate.split("-");
        c.set(Integer.parseInt(strDateValue[0]), Integer.parseInt(strDateValue[1]), Integer.parseInt(strDateValue[2]));
        return c;
    }
    
    public static String getCalendar(JDateChooser date) {
        Calendar c = date.getCalendar();
        int day = c.get(Calendar.DAY_OF_MONTH);
        int month = c.get(Calendar.MONTH);
        int year = c.get(Calendar.YEAR);
        return year+"-"+month+"-"+day;
    }
}
